<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>超市零售系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" th:href="@{/vendor/bootstrap/css/bootstrap.min.css}">
    <link th:href="@{/vendor/fonts/circular-std/style.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/libs/css/style.css}">
    <link rel="stylesheet" th:href="@{/vendor/fonts/fontawesome/css/fontawesome-all.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/dataTables.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/buttons.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/select.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/fixedHeader.bootstrap4.css}">
    <style type="text/css">
        #container {
            overflow: hidden;
        }

        /* 清除浮bai动 */
        /*#container div{width:200px;height:100px;}*/
        .box1 {
            float: left;
        }

        .box2 {
            float: right;
            margin-right: 20px
        }
    </style>
</head>

<body>

<!-- main wrapper -->

<div class="dashboard-main-wrapper">

    <!-- navbar::头部导航栏 -->

    <div class="dashboard-header">
        <div th:insert="~{commons/commons::topBar}"></div>
    </div>

    <!-- end navbar -->


    <!-- left sidebar -->

    <div class="nav-left-sidebar sidebar-dark">
        <div class="menu-list">
            <div th:insert="~{commons/commons::sideBar}"></div>
        </div>
    </div>

    <!-- end left sidebar -->


    <!-- wrapper  -->

    <div class="dashboard-wrapper">
        <div class="container-fluid  dashboard-content">
            <!-- pageheader -->
            <div class="row">
                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="page-header">
                        <h2 class="pageheader-title">盈亏明细</h2>
                        <div class="page-breadcrumb">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <form th:action="@{/statistics/queryAllBySomething}" method="post">
                    <div class="col-lg-3"  style="float: left">
                        <div class="input-group">
                        <span class="input-group-addon">
                             <span class="input-group-text" id="basic-addon1">商品编号</span>
                        </span>
                            <input type="text" name="proId" class="form-control" aria-label="...">
                        </div>
                    </div>
                    <div class="col-lg-3"  style="float: left">
                        <div class="input-group">
                        <span class="input-group-addon">
                             <span class="input-group-text" id="basic-addon2">商品名称</span>
                        </span>
                            <input type="text" name="proName" class="form-control" aria-label="...">
                        </div>
                    </div>
                    <div class="col-lg-3"  style="float: left">
                        <div class="input-group">
                        <span class="input-group-addon">
                             <span class="input-group-text" id="basic-addon3">商品类别</span>
                        </span>
                            <input type="text" name="proClass" class="form-control" aria-label="...">
                        </div>
                    </div>
                    <input type="submit" class="btn btn-primary" value="查询"/>
                    <div class="box2" style="margin-right: 13%"><a class="btn btn-success" th:href="@{/statistics/queryClass}">返回上页</a></div>
            </form>

            <br>

            <!-- end pageheader -->

            <div class="row">

                <!-- basic table  -->

                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered first text-center" id="productTable">
                                    <thead>
                                    <tr>
                                        <th>商品编号</th>
                                        <th>商品名称</th>
                                        <th>商品类别</th>
                                        <th>商品总销售量&nbsp;&nbsp;&nbsp;
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderBySoldDown}"><i
                                                    class="fa fa-arrow-circle-down" aria-hidden="true"></i></a>
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderBySoldUp}"><i class="fa fa-arrow-circle-up"
                                                                                         aria-hidden="true"></i></a>
                                        </th>
                                        <th>报废量&nbsp;&nbsp;&nbsp;
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderByScrapDown}"><i
                                                    class="fa fa-arrow-circle-down" aria-hidden="true"></i></a>
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderByScrapUp}"><i class="fa fa-arrow-circle-up"
                                                                                          aria-hidden="true"></i></a>
                                        <th>商品销盈亏&nbsp;&nbsp;&nbsp;
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderByProfitDown}"><i
                                                    class="fa fa-arrow-circle-down" aria-hidden="true"></i></a>
                                            <a class="btn btn-sm btn" style="border-radius:15px;"
                                               th:href="@{/statistics/orderByProfitUp}"><i class="fa fa-arrow-circle-up"
                                                                                           aria-hidden="true"></i></a>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="product : ${allProducts}">
                                        <td th:text="${product.getProduct_id()}"></td>
                                        <td th:text="${product.getProduct_name()}"></td>
                                        <td th:text="${product.getProduct_class()}"></td>
                                        <td th:text="${product.getProduct_sold()}"></td>
                                        <td th:text="${product.getProduct_scrap()}"></td>
                                        <td th:text="${product.getProduct_profit()}"></td>
                                    </tr>
                                    </tbody>
                                </table>
                                <br>
                                <br>
                                <div>
                                    <div class="box1">
                                        <h1>总盈亏:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
                                    </div>
                                    <div class="box1" th:if="${not #strings.isEmpty(profits)}">
                                        <h1 th:text="${profits}"></h1>
                                    </div>

                                    <div class="box1">
                                        <h1>元&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- end basic table  -->

            </div>
        </div>



    </div>
    <!-- end footer -->
    <div class="footer">
        <div class="container-fluid">
            <div th:insert="~{commons/commons::footer}"></div>
        </div>
    </div>
</div>




<script th:src="@{/vendor/jquery/jquery-3.3.1.min.js}"></script>
<script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.js}"></script>
<script th:src="@{/vendor/slimscroll/jquery.slimscroll.js}"></script>
<script th:src="@{/vendor/multi-select/js/jquery.multi-select.js}"></script>
<script th:src="@{/libs/js/main-js.js}"></script>

<script th:src="@{/vendor/datatables/js/dataTables.bootstrap4.min.js}"></script>
<script th:src="@{/vendor/datatables/js/buttons.bootstrap4.min.js}"></script>
<script th:src="@{/vendor/datatables/js/data-table.js}"></script>

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
    function searchSoldDown() {
        $.ajax({
            url: "/statistics/orderBySoldDown",
            success: function (data) {
                console.log(data);
                $("#productTable tbody").empty();
                $(data).each(function (index, item) {
                    $("#productTable tbody").append(" <tr>\n" +
                        "                                        <td>" + item.product_id + "</td>\n" +
                        "                                        <td>" + item.product_name + "</td>\n" +
                        "                                        <td>" + item.product_class + "</td>\n" +
                        "                                        <td>" + item.product_sold + "</td>\n" +
                        "                                        <td>" + item.product_scrap + "</td>\n" +
                        "                                        <td>" + item.product_profit + "</td>\n" +
                        "<tr/>"
                    );
                })
            }
        })
    }
</script>
</body>

</html>
